package tech.powerjob.server.web.feign;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import tech.powerjob.common.request.http.SaveJobInfoRequest;
import tech.powerjob.common.request.http.SaveWorkflowNodeRequest;
import tech.powerjob.common.response.ResultDTO;
import tech.powerjob.server.core.service.JobService;
import tech.powerjob.server.persistence.remote.model.WorkflowNodeInfoDO;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/feign/job")
public class FeignJobController {

    @Resource
    private JobService jobService;

    @PostMapping("/save")
    public ResultDTO<Long> saveJobInfo(@RequestBody SaveJobInfoRequest request) throws Exception {
        Long id = jobService.saveJob(request);
        return ResultDTO.success(id);
    }

    @GetMapping("/delete")
    public ResultDTO<Void> deleteJob(String jobId) {
        jobService.deleteJob(Long.valueOf(jobId));
        return ResultDTO.success(null);
    }

}
